my application did not show toast mesage when network is not available [closed]

Posted by Smart Guy on Programmers See other posts from Programmers or by Smart Guy
Published on 2012-10-02T10:50:54Z Indexed on 2012/10/02 15:52 UTC
Read the original article Hit count: 253

Filed under:

my application did no show toast message when network is disable

if (position == 2)

            {

                final ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
                NetworkInfo activeNetworkInfo = connMgr .getActiveNetworkInfo();
                android.net.NetworkInfo mobile1 = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

                if (activeNetworkInfo == null) {
                    Toast.makeText(LoginScreen.this, "No Active Network",Toast.LENGTH_LONG).show();
                } else {

                    if (activeNetworkInfo.isConnected()) {

                                btnLogin.setOnClickListener(new OnClickListener() {

public  void onClick(View view) {
String pinemptycheck = pin.getText().toString();
String mobileemptycheck = mobile.getText().toString();
 if  (pinemptycheck.trim().equals("")||(mobileemptycheck.trim().equals("")))
                                 {


 Toast.makeText(getApplicationContext(), "Please Enter Correct Information", 
    Toast.LENGTH_LONG).show();

 } 


 else
 {

showProgress();
postLoginData();
 }



}
});
} else if (activeNetworkInfo.isConnectedOrConnecting()) {

Toast.makeText(LoginScreen.this,    "network is Connecting", Toast.LENGTH_LONG)  
 .show();
 else if (mobile1.isAvailable()) {

btnLogin.setOnClickListener(new OnClickListener() {
public  void onClick(View view) {

showProgress();

  postLoginData();                                  

 }
    });
    } else if (!mobile1.isAvailable()) {

   Toast.makeText(LoginScreen.this,"No other Connection Found    
  ",Toast.LENGTH_LONG).show();
    btnLogin.setOnClickListener(new 
  OnClickListener() {
public void onClick(View v)

{

       Toast.makeText(LoginScreen.this," No other Connection Found",  
Toast.LENGTH_LONG).show();
                            }

});
}}}

© Programmers or respective owner

Related posts about android